package demo.java.springboot.jpa.service.impl;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import demo.java.springboot.jpa.repository.UserRepository;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import demo.java.springboot.jpa.po.User;
import demo.java.springboot.jpa.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	private static Logger LOG = LogManager.getLogger(UserServiceImpl.class);

	@Resource // @Autowired
	private UserRepository userRepository;
	
	@Override
	public User authenticate(String user, String password) {
		User u = userRepository.findByLoginName(user);
		if (!u.getPassword().equals(password)) {
			return null;
		}
		return u;
	}
}
